function register()
{
    if (!nameTxt.text.trim()) {
        dialog.message("姓名不可为空!");
        return
    }

    if (mobileTxt.text.trim().length !== 11){
        dialog.message("手机号码不正确!");
        return;
    }

    if (passwordTxt.text.trim().length < 6)
    {
        dialog.message("密码不能小于6位!");
        return;
    }

    if (passText.text.trim() != passwordTxt.text.trim()) {
        dialog.message("两次密码不一致!");
        return;
    }

    nav.initializeTask(0, 2, "正在注册账号......")
    dialog.task("账号注册", nav);

    var school = model_School.get(listSchool.currentIndex)
    var teacher = modelTeacher.get(listTeacher.currentIndex)

    http.post("/member.json", {}, {mobile: mobileTxt.text.trim(),
                       password: Qt.md5(passwordTxt.text.trim()).toUpperCase(),
                       name: nameTxt.text.trim(),

                       school: {
                           id: school.id,
                           display: school.name
                       },
                       parent: {
                           id: teacher.id,
                           display: teacher.name
                       },
                       role:"s",
                       mail: mailTxt.text
                   }, regResult)

    nav.value++
}

function regResult(json)
{
    nav.value = nav.maximumValue


    if (json.error) {
        dialog.message(json.error.description)
        return
    }

    dialog.yesno('注册成功, 是否登录？', function(cancelled){
        if (!cancelled) {
            contentArea.navigate("../qml/LoginNavigator.qml");
        }
    })
}


